// author by welong
// zuowl@qq.com
// 2014-09-06  10:56
// PAT basic 1022

#include <stdio.h>
#include <string.h>
#include <stdlib.h>

int main(int argc, char **argv)	// input 0 0 8, cause test site 3 error
{
	int a, b, base;
	int i, sum = 0;
	char output[35] = {0};

	int  len, jlen;
	char temp;

	scanf("%d%d%d", &a, &b, &base);
	sum = a + b;

	for(i = 0; sum != 0; i++)
	{
		output[i] = sum % base + '0';
		sum /= base;
	}
	//*
	len = strlen(output);
	if(len == 0)
	{
		output[0] = '0';
		output[1] = 0;
		printf("%s\n", output);
		return 0;
	}

	jlen = len - 1;
	len /= 2;

	for(i = 0; i < len ; i++)
	{
		temp = output[i];
		output[i] = output[jlen - i];
		output[jlen - i] = temp;
	}
	//*/
	printf("%s\n", output);
	return 0;
}